home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / oss.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  21.7 KB  |  832 lines

  1. /*      oss.c
  2.  *
  3.  * Open Sound System Sound Devicee
  4.  *
  5.  * $Id: oss.c,v 1.11 1996/11/09 21:08:04 jpaana Exp $
  6.  *
  7.  * Copyright 1996 Petteri Kangaslampi and Jarno Paananen
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16. #include <stdio.h>
  17. #include <sys/ioctl.h>
  18. #include <unistd.h>
  19. #include <fcntl.h>
  20. #include <sys/soundcard.h>
  21.  
  22. #include "lang.h"
  23. #include "mtypes.h"
  24. #include "errors.h"
  25. #include "sdevice.h"
  26. #include "mmem.h"
  27. #include "dsm.h"
  28. #include "mglobals.h"
  29.  
  30.  
  31. RCSID(char const *oss_rcsid = "$Id: oss.c,v 1.11 1996/11/09 21:08:04 jpaana Exp $";)
  32.  
  33. #define DEVICE_NAME "/dev/dsp"
  34.  
  35. #define open_mode O_WRONLY
  36.  
  37. static    int audio_fd;
  38. static    int format_16bits = AFMT_S16_LE;
  39. static    int format_8bits = AFMT_U8;
  40. static    int format_stereo;
  41. static    int format_mixingrate;
  42. static    audio_buf_info info;
  43. static    uchar *audioBuffer;
  44. static    int audioBufferSize;
  45.  
  46. /* Make that "e" smaller (to c or even a) if you have small DMA buffer */
  47.  
  48. static    int numFragments = 0xffff000e;
  49.  
  50. //#define DUMPBUFFER
  51.  
  52. #define OSSVERSION 1.02
  53. #define OSSVERSTR "1.02"
  54.  
  55. /* Number of bits of accuracy in mixing for 8-bit output: */
  56. #define MIX8BITS 12
  57.  
  58.  
  59. /* Sound Device information */
  60.  
  61.     /* Sound Card names: */
  62. static char     *ossCardName = "Unix Sound System output";
  63.  
  64.  
  65.  
  66. /* Sound Device internal static variables */
  67. static unsigned mixRate, outputMode;
  68. static unsigned mixElemSize;
  69.  
  70. static unsigned amplification;
  71. static unsigned updateMix;              /* number of elements to mix between
  72.                                            two updates */
  73. static unsigned mixLeft;                /* number of elements to mix before
  74.                                            next update */
  75.  
  76. static unsigned bufferPos;               /* mixing position inside buffer */
  77.  
  78. static uchar    *ppTable;               /* post-processing table for 8-bit
  79.                                            output */
  80.  
  81. #ifdef DUMPBUFFER
  82. static FILE     *buff;
  83. #endif
  84.  
  85.  
  86. /****************************************************************************\
  87. *       enum ossFunctIDs
  88. *       -----------------
  89. * Description:  ID numbers for OSS Sound Device functions
  90. \****************************************************************************/
  91.  
  92. enum ossFunctIDs
  93. {
  94.     ID_ossDetect = ID_oss,
  95.     ID_ossInit,
  96.     ID_ossClose,
  97.     ID_ossGetMode,
  98.     ID_ossOpenChannels,
  99.     ID_ossSetAmplification,
  100.     ID_ossGetAmplification,
  101.     ID_ossSetUpdRate,
  102.     ID_ossStartPlay,
  103.     ID_ossPlay
  104. };
  105.  
  106.  
  107.  
  108. /* Local prototypes: */
  109. int CALLING ossSetAmplification(unsigned _amplification);
  110. int CALLING ossGetAmplification(unsigned *_amplification);
  111. int CALLING ossSetUpdRate(unsigned updRate);
  112.  
  113. /****************************************************************************\
  114. *
  115. * Function:     static unsigned CALLING (*postProc)(unsigned numElements,
  116. *                   uchar *bufStart, unsigned mixPos, unsigned *mixBuffer,
  117. *                   uchar *ppTable);
  118. *
  119. * Description:  Pointer to the actual post-processing routine. Takes
  120. *               DSM output elements from dsmMixBuffer and writes them to
  121. *               output buffer at *bufStart in a format suitable for the Sound
  122. *               Device.
  123. *
  124. * Input:        unsigned numElements    number of elements to process
  125. *                                       (guaranteed to be even)
  126. *               uchar *bufStart         pointer to start of output buffer
  127. *               unsigned mixPos         mixing position in output buffer
  128. *               unsigned *mixBuffer     source mixing buffer
  129. *               uchar *ppTable          pointer to post-processing table
  130. *
  131. * Returns:      New mixing position in output buffer. Can not fail.
  132. *
  133. \****************************************************************************/
  134.  
  135. static unsigned CALLING (*postProc)(unsigned numElements, uchar *bufStart,
  136.     unsigned mixPos, unsigned *mixBuffer, uchar *ppTable);
  137.  
  138.  
  139. /****************************************************************************\
  140. *
  141. * Function:     unsigned pp16Mono();
  142. *
  143. * Description:  16-bit mono post-processing routine
  144. *
  145. \****************************************************************************/
  146.  
  147. unsigned CALLING pp16Mono(unsigned numElements, uchar *bufStart,
  148.     unsigned mixPos, unsigned *mixBuffer, uchar *ppTable);
  149.  
  150. /****************************************************************************\
  151. *
  152. * Function:     unsigned pp8Mono();
  153. *
  154. * Description:  8-bit mono post-processing routine
  155. *
  156. \****************************************************************************/
  157.  
  158. unsigned CALLING pp8Mono(unsigned numElements, uchar *bufStart,
  159.     unsigned mixPos, unsigned *mixBuffer, uchar *ppTable);
  160.  
  161. /****************************************************************************\
  162. *
  163. * Function:     unsigned pp16Stereo();
  164. *
  165. * Description:  16-bit stereo post-processing routine
  166. *
  167. \****************************************************************************/
  168.  
  169. unsigned CALLING pp16Stereo(unsigned numElements, uchar *bufStart,
  170.     unsigned mixPos, unsigned *mixBuffer, uchar *ppTable);
  171.  
  172. /****************************************************************************\
  173. *
  174. * Function:     unsigned pp8Stereo();
  175. *
  176. * Description:  8-bit stereo post-processing routine
  177. *
  178. \****************************************************************************/
  179.  
  180. unsigned CALLING pp8Stereo(unsigned numElements, uchar *bufStart,
  181.     unsigned mixPos, unsigned *mixBuffer, uchar *ppTable);
  182.  
  183.  
  184. /****************************************************************************\
  185. *
  186. * Function:     int ossDetect(int *result)
  187. *
  188. * Description:  Detects a OSS Sound Device
  189. *
  190. * Input:        int *result             pointer to detection result
  191. *
  192. * Returns:      MIDAS error code. Detection result (1 if detected, 0 if not)
  193. *               is written to *result.
  194. *
  195. * Notes:        OSS Sound Device is always detected.
  196. *
  197. \****************************************************************************/
  198.  
  199. int CALLING ossDetect(int *result)
  200. {
  201.     *result = 1;
  202.     return OK;
  203. }
  204.  
  205.  
  206.  
  207.  
  208. /****************************************************************************\
  209. *
  210. * Function:     int ossInit(unsigned mixRate, unsigned mode)
  211. *
  212. * Description:  Initializes OSS Sound Device
  213. *
  214. * Input:        unsigned mixRate        mixing rate in Hz
  215. *               unsigned mode           output mode
  216. *
  217. * Returns:      MIDAS error code
  218. *
  219. \****************************************************************************/
  220.  
  221. int CALLING ossInit(unsigned _mixRate, unsigned mode)
  222. {
  223.     int         error;
  224.     int         mixMode;
  225.     int         *modetag;
  226.  
  227.     mixRate = _mixRate;
  228.  
  229.     /* Determine the actual output mode: */
  230.     if ( mode & sdMono )
  231.     format_stereo = 0;
  232.     else
  233.     format_stereo = 1;
  234.  
  235.     if ( mode & sd8bit )
  236.     modetag = &format_8bits;
  237.     else
  238.     modetag = &format_16bits;
  239.  
  240.     /* Open output device using the format just set up: */
  241.     if (( audio_fd = open(DEVICE_NAME, open_mode, 0 )) == -1 )
  242.     {
  243.     perror(DEVICE_NAME);
  244.     return errDeviceNotAvailable;
  245.     }
  246.  
  247.     if ( ((int)mode = ioctl(audio_fd, SNDCTL_DSP_SETFMT, modetag)) == -1)
  248.     { /* Fatal error */
  249.         perror("SNDCTL_DSP_SETFMT");
  250.     return(errSDFailure);
  251.     }
  252.  
  253.     if (ioctl(audio_fd, SNDCTL_DSP_STEREO, &format_stereo) == -1)
  254.     { /* Fatal error */
  255.         perror("SNDCTL_DSP_STEREO");
  256.     return(errSDFailure);
  257.     }
  258.     
  259.     if (format_stereo)
  260.         outputMode = sdStereo;
  261.     else
  262.         outputMode = sdMono;
  263.  
  264.     if ( *modetag == AFMT_U8 )
  265.         outputMode |= sd8bit;
  266.     else
  267.     {
  268.         if ( *modetag == AFMT_S16_LE )
  269.             outputMode |= sd16bit;
  270.         else
  271.         return(errSDFailure);
  272.     }
  273.  
  274.     format_mixingrate = mixRate;
  275.  
  276.     if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &format_mixingrate) == -1)
  277.     { /* Fatal error */
  278.         perror("SNDCTL_DSP_SPEED");
  279.     return(errSDFailure);
  280.     }
  281.  
  282.     mixRate = format_mixingrate;
  283.     
  284.     /* Calculate one mixing element size: */
  285.     if ( outputMode & sd16bit )
  286.         mixElemSize = 2;
  287.     else
  288.         mixElemSize = 1;
  289.     if ( outputMode & sdStereo )
  290.         mixElemSize <<= 1;
  291.  
  292.     /* Allocate memory for post-processing table if necessary: */
  293.     if ( outputMode & sd8bit )
  294.     {
  295.         /* Allocate memory for 8-bit output mode post-processing table: */
  296.         if ( (error = memAlloc((1 << MIX8BITS), (void**)&ppTable)) != OK )
  297.             PASSERROR(ID_ossInit);
  298.     }
  299.     else
  300.         ppTable = NULL;
  301.  
  302.  
  303.     /* Check correct mixing mode: */
  304.     if ( outputMode & sdStereo )
  305.         mixMode = dsmMixStereo;
  306.     else
  307.         mixMode = dsmMixMono;
  308.  
  309.     /* Initialize Digital Sound Mixer: */
  310.     if ( outputMode & sd16bit )
  311.     {
  312.         if ( (error = dsmInit(mixRate, mixMode, 16)) != OK )
  313.             PASSERROR(ID_ossInit)
  314.     }
  315.     else
  316.     {
  317.         if ( (error = dsmInit(mixRate, mixMode, MIX8BITS)) != OK )
  318.             PASSERROR(ID_ossInit)
  319.     }
  320.  
  321.     /* Set update rate to 50Hz: */
  322.     if ( (error = ossSetUpdRate(5000)) != OK )
  323.         PASSERROR(ID_ossInit)
  324.  
  325.     /* Allocate memory for audiobuffer: */
  326.  
  327.     if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &numFragments) == -1)
  328.     { /* Fatal error */
  329.         perror("SNDCTL_DSP_SETFRAGMENT");
  330.     return(errSDFailure);
  331.     }
  332.  
  333.     
  334.     if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
  335.     { /* Fatal error */
  336.         perror("SNDCTL_DSP_GETOSPACE");
  337.     return(errSDFailure);
  338.     }
  339.  
  340. //    printf("Fragment size: %i, total fragments: %i\n", info.fragsize, info.fragstotal);
  341.  
  342. //    audioBufferSize = mixRate * mixElemSize * mBufferLength / 1000;
  343.     audioBufferSize = dsmMixBufferSize;
  344. //    audioBufferSize = info.fragsize;
  345.  
  346.     if ( (error = memAlloc(audioBufferSize, (void**)&audioBuffer)) != OK )
  347.         PASSERROR(ID_ossInit);
  348.  
  349.  
  350.     /* Point postProc() to correct post-processing routine: */
  351.     switch ( outputMode )
  352.     {
  353.         case (sd16bit | sdMono):
  354.             postProc = &pp16Mono;
  355.             break;
  356.  
  357.         case (sd8bit | sdMono):
  358.             postProc = &pp8Mono;
  359.             break;
  360.  
  361.         case (sd16bit | sdStereo):
  362.             postProc = &pp16Stereo;
  363.             break;
  364.  
  365.         case (sd8bit | sdStereo):
  366.             postProc = &pp8Stereo;
  367.             break;
  368.  
  369.         default:
  370.             ERROR(errInvalidArguments, ID_ossInit);
  371.             return errInvalidArguments;
  372.     }
  373.  
  374.     amplification = 64;
  375.  
  376. #ifdef DUMPBUFFER
  377.     buff = fopen("buffer.raw", "wb");
  378. #endif
  379.     return OK;
  380. }
  381.  
  382.  
  383.  
  384.  
  385. /****************************************************************************\
  386. *
  387. * Function:     ossClose(void)
  388. *
  389. * Description:  Uninitializes OSS Sound Device
  390. *
  391. * Returns:      MIDAS error code
  392. *
  393. \****************************************************************************/
  394.  
  395. int ossClose(void)
  396. {
  397.     int         error;
  398.  
  399. #ifdef DUMPBUFFER
  400.     fclose(buff);
  401. #endif
  402.  
  403.     /* Uninitialize Digital Sound Mixer: */
  404.     if ( (error = dsmClose()) != OK )
  405.         PASSERROR(ID_ossClose)
  406.  
  407.     /* Deallocate post-processing table if necessary: */
  408.     if ( outputMode & sd8bit )
  409.     {
  410.         if ( (error = memFree(ppTable)) != OK )
  411.             PASSERROR(ID_ossClose);
  412.     }
  413.  
  414.     /* Deallocate audio buffer */
  415.     if ( (error = memFree(audioBuffer)) != OK )
  416.       PASSERROR(ID_ossClose);
  417.  
  418.     close(audio_fd);
  419.  
  420.     return OK;
  421. }
  422.  
  423.  
  424.  
  425.  
  426. /****************************************************************************\
  427. *
  428. * Function:     int ossGetMode(unsigned *mode)
  429. *
  430. * Description:  Reads the current output mode
  431. *
  432. * Input:        unsigned *mode          pointer to output mode
  433. *
  434. * Returns:      MIDAS error code. Output mode is written to *mode.
  435. *
  436. \****************************************************************************/
  437.  
  438. int CALLING ossGetMode(unsigned *mode)
  439. {
  440.     *mode = outputMode;
  441.  
  442.     return OK;
  443. }
  444.  
  445.  
  446.  
  447.  
  448. /****************************************************************************\
  449. *
  450. * Function:     int ossOpenChannels(unsigned channels)
  451. *
  452. * Description:  Opens sound channels for output. Prepares post-processing
  453. *               tables, takes care of default amplification and finally opens
  454. *               DSM channels. Channels can be closed by simply calling
  455. *               dsmCloseChannels().
  456. *
  457. * Input:        unsigned channels       number of channels to open
  458. *
  459. * Returns:      MIDAS error code
  460. *
  461. \****************************************************************************/
  462.  
  463. int CALLING ossOpenChannels(unsigned channels)
  464. {
  465.     int         error;
  466.  
  467.     /* Open DSM channels: */
  468.     if ( (error = dsmOpenChannels(channels)) != OK )
  469.         PASSERROR(ID_ossOpenChannels)
  470.  
  471.     /* Take care of default amplification and calculate new post-processing
  472.        table if necessary: */
  473.  
  474.         if ( channels < 5 )
  475.             ossSetAmplification(64);
  476.         else
  477.             ossSetAmplification(14*channels);
  478.  
  479.     return OK;
  480. }
  481.  
  482.  
  483.  
  484.  
  485. /****************************************************************************\
  486. *
  487. * Function:     void CalcPP8Table(void)
  488. *
  489. * Description:  Calculates a new 8-bit output post-processing table using
  490. *               current amplification level
  491. *
  492. \****************************************************************************/
  493.  
  494. static void CalcPP8Table(void)
  495. {
  496.     uchar       *tbl;
  497.     int         val;
  498.     long        temp;
  499.  
  500.     tbl = ppTable;                      /* tbl points to current table pos */
  501.  
  502.     /* Calculate post-processing table for all possible DSM values:
  503.        (table must be used with unsigned numbers - add (1 << MIX8BITS)/2 to
  504.        DSM output values first) */
  505.     for ( val = -(1 << MIX8BITS)/2; val < (1 << MIX8BITS)/2; val++ )
  506.     {
  507.         /* Calculate 8-bit unsigned output value corresponding to the
  508.            current DSM output value (val), taking amplification into
  509.            account: */
  510.         temp = 128 + ((((long) amplification) * ((long) val) / 64L) >>
  511.             (MIX8BITS-8));
  512.  
  513.         /* Clip the value to fit between 0 and 255 inclusive: */
  514.         if ( temp < 0 )
  515.             temp = 0;
  516.         if ( temp > 255 )
  517.             temp = 255;
  518.  
  519.         /* Write the value to the post-processing table: */
  520.         *(tbl++) = (uchar) temp;
  521.     }
  522. }
  523.  
  524.  
  525.  
  526.  
  527. /****************************************************************************\
  528. *
  529. * Function:     int ossSetAmplification(unsigned amplification)
  530. *
  531. * Description:  Sets the amplification level. Calculates new post-processing
  532. *               tables and calls dsmSetAmplification() as necessary.
  533. *
  534. * Input:        unsigned amplification  amplification value
  535. *
  536. * Returns:      MIDAS error code
  537. *
  538. \****************************************************************************/
  539.  
  540. int CALLING ossSetAmplification(unsigned _amplification)
  541. {
  542.     int         error;
  543.  
  544.     amplification = _amplification;
  545.  
  546.     if ( outputMode & sd8bit )
  547.     {
  548.         /* 8-bit output mode - do not set amplification level using DSM,
  549.            but calculate a new post-processing table instead: */
  550.         CalcPP8Table();
  551.     }
  552.     else
  553.     {
  554.         /* Set amplification level to DSM: */
  555.         if ( (error = dsmSetAmplification(amplification)) != OK )
  556.             PASSERROR(ID_ossSetAmplification)
  557.     }
  558.  
  559.     return OK;
  560. }
  561.  
  562.  
  563.  
  564.  
  565. /****************************************************************************\
  566. *
  567. * Function:     int ossGetAmplification(unsigned *amplification);
  568. *
  569. * Description:  Reads the current amplification level. (DSM doesn't
  570. *               necessarily know the actual amplification level if
  571. *               post-processing takes care of amplification)
  572. *
  573. * Input:        unsigned *amplification   pointer to amplification level
  574. *
  575. * Returns:      MIDAS error code. Amplification level is written to
  576. *               *amplification.
  577. *
  578. \****************************************************************************/
  579.  
  580. int CALLING ossGetAmplification(unsigned *_amplification)
  581. {
  582.     *_amplification = amplification;
  583.  
  584.     return OK;
  585. }
  586.  
  587.  
  588.  
  589.  
  590. /****************************************************************************\
  591. *
  592. * Function:     int ossSetUpdRate(unsigned updRate);
  593. *
  594. * Description:  Sets the channel value update rate (depends on song tempo)
  595. *
  596. * Input:        unsigned updRate        update rate in 100*Hz (eg. 50Hz
  597. *                                       becomes 5000).
  598. *
  599. * Returns:      MIDAS error code
  600. *
  601. \****************************************************************************/
  602.  
  603. int CALLING ossSetUpdRate(unsigned updRate)
  604. {
  605.     /* Calculate number of elements to mix between two updates: (even) */
  606.     mixLeft = updateMix = ((unsigned) ((100L * (ulong) mixRate) /
  607.         ((ulong) updRate)) + 1) & 0xFFFFFFFE;
  608.  
  609.     return OK;
  610. }
  611.  
  612.  
  613.  
  614.  
  615. /****************************************************************************\
  616. *
  617. * Function:     int ossStartPlay(void)
  618. *
  619. * Description:  Prepares for playing - doesn't actually do anything here...
  620. *
  621. * Returns:      MIDAS error code
  622. *
  623. \****************************************************************************/
  624.  
  625. int CALLING ossStartPlay(void)
  626. {
  627.     return OK;
  628. }
  629.  
  630.  
  631.  
  632.  
  633. /****************************************************************************\
  634. *
  635. * Function:     int ossPlay(int *callMP);
  636. *
  637. * Description:  Plays the sound - mixes the correct amount of data with DSM
  638. *               and copies it to output buffer with post-processing.
  639. *               Also takes care of sending fully mixed buffer to the 
  640. *               output device.
  641. *
  642. * Input:        int *callMP             pointer to music player calling flag
  643. *
  644. * Returns:      MIDAS error code. If enough data was mixed for one updating
  645. *               round and music player should be called, 1 is written to
  646. *               *callMP, otherwise 0 is written there. Note that if music
  647. *               player can be called, ossPlay() should be called again
  648. *               with a new check for music playing to ensure the mixing buffer
  649. *               gets filled with new data.
  650. *
  651. \****************************************************************************/
  652.  
  653. int CALLING ossPlay(int *callMP)
  654. {
  655.     int         error;
  656.     unsigned    bufferLeft, numElems;
  657.     unsigned    dsmBufSize;
  658. //    uchar       *temp;
  659.  
  660.     if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) == -1)
  661.     { /* Fatal error */
  662.         perror("SNDCTL_DSP_GETOSPACE");
  663.     return(errSDFailure);
  664.     }
  665.  
  666. //    printf("avail frags: %i\n", info.fragments);
  667.  
  668.     if ( info.fragments == 0 )
  669.     {
  670.         *callMP = 0;
  671.         return OK;
  672.     }
  673.  
  674.     /* Calculate DSM mixing buffer size in elements: (FIXME) */
  675.     dsmBufSize = dsmMixBufferSize;
  676.     dsmBufSize >>= 2;
  677.  
  678.  
  679.     if ( outputMode & sdStereo )
  680.         dsmBufSize >>= 1;
  681.  
  682.     /* Calculate number of bytes of buffer left: */
  683.  
  684.     bufferLeft = audioBufferSize - bufferPos;
  685.  
  686.     /* Calculate number of mixing elements left: */
  687.     numElems = bufferLeft / mixElemSize;
  688.  
  689.     /* Check that we won't mix more data than there is to the next
  690.        update: */
  691.     if ( numElems > mixLeft )
  692.         numElems = mixLeft;
  693.  
  694.     /* Check that we won't mix more data than fits to DSM mixing
  695.        buffer: */
  696.     if ( numElems > dsmBufSize )
  697.         numElems = dsmBufSize;
  698.  
  699.     /* Decrease number of elements before next update: */
  700.     mixLeft -= numElems;
  701.  
  702.     /* Mix the data to DSM mixing buffer: */
  703.     if ( (error = dsmMixData(numElems)) != OK )
  704.         PASSERROR(ID_ossPlay)
  705.  
  706.     /* Write the mixed data to output buffer: */
  707.     bufferPos = postProc(numElems, audioBuffer, 0,
  708.         dsmMixBuffer, ppTable);
  709.  
  710. #ifdef DUMPBUFFER
  711.     fwrite(&audioBuffer[oldPos], numElems * mixElemSize, 1, buff);
  712. #endif
  713.  
  714.  
  715.     /* Check if the buffer is full - if so, write it to the output
  716.        device and start over: */
  717.  
  718.     write(audio_fd, audioBuffer, bufferPos);
  719.  
  720.     /* Check if the music player should be called: */
  721.     if ( mixLeft == 0)
  722.     {
  723.         mixLeft = updateMix;
  724.         *callMP = 1;
  725.         return OK;
  726.     }
  727.  
  728.     /* No more data fits to the mixing buffers - just return without
  729.        update: */
  730.     *callMP = 0;
  731.  
  732.     return OK;
  733. }
  734.  
  735.  
  736.  
  737.  
  738.     /* OSS Sound Device structure: */
  739.  
  740. SoundDevice     OSS = {
  741.     0,                                  /* tempoPoll = 0 */
  742.     sdUseMixRate | sdUseOutputMode | sdUseDSM,  /* configBits */
  743.     0,                                  /* port */
  744.     0,                                  /* IRQ */
  745.     0,                                  /* DMA */
  746.     1,                                  /* cardType */
  747.     1,                                  /* numCardTypes */
  748.     sdMono | sdStereo | sd8bit | sd16bit,       /* modes */
  749.  
  750.     "Open Sound System Sound Device " OSSVERSTR,              /* name */
  751.     &ossCardName,                               /* cardNames */
  752.     0,                                          /* numPortAddresses */
  753.     NULL,                                       /* portAddresses */
  754.  
  755.     &ossDetect,
  756.     &ossInit,
  757.     &ossClose,
  758.     &dsmGetMixRate,
  759.     &ossGetMode,
  760.     &ossOpenChannels,
  761.     &dsmCloseChannels,
  762.     &dsmClearChannels,
  763.     &dsmMute,
  764.     &dsmPause,
  765.     &dsmSetMasterVolume,
  766.     &dsmGetMasterVolume,
  767.     &ossSetAmplification,
  768.     &ossGetAmplification,
  769.     &dsmPlaySound,
  770.     &dsmReleaseSound,
  771.     &dsmStopSound,
  772.     &dsmSetRate,
  773.     &dsmGetRate,
  774.     &dsmSetVolume,
  775.     &dsmGetVolume,
  776.     &dsmSetSample,
  777.     &dsmGetSample,
  778.     &dsmSetPosition,
  779.     &dsmGetPosition,
  780.     &dsmGetDirection,
  781.     &dsmSetPanning,
  782.     &dsmGetPanning,
  783.     &dsmMuteChannel,
  784.     &dsmAddSample,
  785.     &dsmRemoveSample,
  786.     &ossSetUpdRate,
  787.     &ossStartPlay,
  788.     &ossPlay
  789. };
  790.  
  791.  
  792. /*
  793.  * $Log: oss.c,v $
  794.  * Revision 1.11  1996/11/09 21:08:04  jpaana
  795.  * Fixed some "comparison between signed and unsigned" warnings
  796.  *
  797.  * Revision 1.10  1996/09/22 17:11:56  jpaana
  798.  * Still tweaking...
  799.  *
  800.  * Revision 1.9  1996/09/21 17:18:01  jpaana
  801.  * Misc Fixes
  802.  *
  803.  * Revision 1.8  1996/09/21 16:40:26  jpaana
  804.  * Fixed some typos
  805.  *
  806.  * Revision 1.7  1996/09/21 16:38:00  jpaana
  807.  * Renamed to Open Sound System Sound Device (blah)
  808.  *
  809.  * Revision 1.6  1996/09/15 09:18:28  jpaana
  810.  * Removed some debug texts
  811.  *
  812.  * Revision 1.5  1996/09/09 09:52:12  jpaana
  813.  * Added some more fragments
  814.  *
  815.  * Revision 1.4  1996/09/08 20:32:32  jpaana
  816.  * Misc. tweaking (most commented out now)
  817.  *
  818.  * Revision 1.3  1996/08/03 13:16:42  jpaana
  819.  * Fixed to work without Pthreads ;)
  820.  *
  821.  * Revision 1.1  1996/06/05 19:40:35  jpaana
  822.  * Initial revision
  823.  *
  824.  * Revision 1.2  1996/05/25 15:49:57  jpaana
  825.  * Cleaned up
  826.  *
  827.  * Revision 1.1  1996/05/24 20:40:12  jpaana
  828.  * Initial revision
  829.  *
  830.  *
  831. */
  832.